package com.ruoyi.applet.order.service.impl;

import com.ruoyi.applet.order.domain.OrdOrderCommodity;
import com.ruoyi.applet.order.mapper.OrdOrderCommodityMapper;
import com.ruoyi.applet.order.service.IOrdOrderCommodityService;
import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 订单商品Service业务层处理
 * @author ruoyi
 * @date 2025-01-02
 */
@Service
public class OrdOrderCommodityServiceImpl implements IOrdOrderCommodityService {
    
    @Resource
    private OrdOrderCommodityMapper ordOrderCommodityMapper;
    
    /**
     * 查询订单商品
     * @param id 订单商品主键
     * @return 订单商品
     */
    @Override
    public OrdOrderCommodity selectOrdOrderCommodityById(Long id) {
        return ordOrderCommodityMapper.selectOrdOrderCommodityById(id);
    }
    
    /**
     * 查询订单商品列表
     * @param ordOrderCommodity 订单商品
     * @return 订单商品
     */
    @Override
    public List<OrdOrderCommodity> selectOrdOrderCommodityList(OrdOrderCommodity ordOrderCommodity) {
        return ordOrderCommodityMapper.selectOrdOrderCommodityList(ordOrderCommodity);
    }
    
    /**
     * 新增订单商品
     * @param ordOrderCommodity 订单商品
     * @return 结果
     */
    @Override
    public int insertOrdOrderCommodity(OrdOrderCommodity ordOrderCommodity) {
        ordOrderCommodity.setCreateTime(DateUtils.getNowDate());
        return ordOrderCommodityMapper.insertOrdOrderCommodity(ordOrderCommodity);
    }
    
    /**
     * 修改订单商品
     * @param ordOrderCommodity 订单商品
     * @return 结果
     */
    @Override
    public int updateOrdOrderCommodity(OrdOrderCommodity ordOrderCommodity) {
        ordOrderCommodity.setUpdateTime(DateUtils.getNowDate());
        return ordOrderCommodityMapper.updateOrdOrderCommodity(ordOrderCommodity);
    }
    
    /**
     * 批量删除订单商品
     * @param ids 需要删除的订单商品主键
     * @return 结果
     */
    @Override
    public int deleteOrdOrderCommodityByIds(String ids) {
        return ordOrderCommodityMapper.deleteOrdOrderCommodityByIds(Convert.toStrArray(ids));
    }
    
    /**
     * 删除订单商品信息
     * @param id 订单商品主键
     * @return 结果
     */
    @Override
    public int deleteOrdOrderCommodityById(Long id) {
        return ordOrderCommodityMapper.deleteOrdOrderCommodityById(id);
    }
}
